package com.jf.juc.c_000;

public class T004_ThreadState {
    static class MyThread extends Thread {
        @Override
        public void run() {
            System.out.println(" run " + this.getState());
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(i);
            }
        }
    }

    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        System.out.println(myThread.getState());
        myThread.start();// start后，就进入了 Runable 状态了。

        try {
            myThread.join();// 结束了 是一个 Timenated 状态。
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(" main " + myThread.getState());
    }
}
